package com.ruoyi.produce.base.design.service;


import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.produce.base.design.domain.ProduceDesign;
import com.ruoyi.produce.base.design.mapper.ProduceDesignMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品设计
 * 业务处理层
 * @author Drj 2021/6/28
 */
@Service
public class ProduceDesignServiceImpl implements IProduceDesignService{

    @Autowired
    private ProduceDesignMapper produceDesignMapper;

    /**
     * 查找产品设计
     *
     * @param produceDesign
     * @return
     */
    @Override
    public List<ProduceDesign> selectProduceDesignList(ProduceDesign produceDesign) {
        return produceDesignMapper.selectProduceDesignList(produceDesign);
    }

    /**
     * 根据id查找产品设计
     *
     * @param designId 设计编号
     * @return
     */
    @Override
    public ProduceDesign selectProduceDesignById(String designId) {
        return produceDesignMapper.selectProduceDesignById(designId);
    }

    /**
     * 新增产品设计
     *
     * @param produceDesign
     * @return
     */
    @Override
    public int insertProduceDesign(ProduceDesign produceDesign) {
        if (StringUtils.isNotNull(produceDesignMapper.selectProduceDesignById(produceDesign.getDesignId()))){
            //存在
            return 0;
        }
        return produceDesignMapper.insertProduceDesign(produceDesign);
    }

    /**
     * 更新产品设计
     *
     * @param produceDesign
     * @return
     */
    @Override
    public int updateProduceDesign(ProduceDesign produceDesign) {
        if (!StringUtils.isNotNull(produceDesignMapper.selectProduceDesignById(produceDesign.getDesignId()))){
            //存在
            return 0;
        }
        return produceDesignMapper.updateProduceDesign(produceDesign);
    }

    /**
     * 删除产品设计
     * 仅修改产品设计删除标志
     *
     * @param produceDesign
     * @return
     */
    @Override
    public int updateProduceDesignDeleteFlag(ProduceDesign produceDesign) {
        return produceDesignMapper.updateProduceDesignDeleteFlag(produceDesign);
    }
}
